home *** CD-ROM | disk | FTP | other *** search
- Speak Procedure
-
- `procedure to speak the contents of every enterable field on a layout
- `written by René G.A. Ros, author of Speech Pack external
- `date: 12 October 1993
- `use with Speech Pack 2.1 or later
- `needs 4th Dimension 2.1 or later
-
- `syntax:
- `SPEAK(pointer;selector)
- `where:
- `pointer is a pointer to the object i.e. obtained by using Last Area
- `selector specifies the type of action undertaken
- `0 = non, redraw buttons only
- `1 = play
- `2 = stop
- `3 = pause
- `for the compiler put this somewhere else:
- `C_POINTER("SPEAK";$1)
- `C_INTEGER("SPEAK";$2)
- `(I'am I correct? I don't use the compiler and no v3 manuals available)
-
- `this procedure assumes:
- `- in the startup procedure a voice was opened by using:
- ` C_INTEGER($err;SpeechRef)
- ` $err := SP Voice Open("*";SpeechRef)
- `- the voice will be closed properly in any quit procedure:
- ` $err := SP Voice Close(SpeechRef)
- ` (4D v3 USERS CAN MAKE SpeechRef A INTERPROCESS VARIABLE)
-
- `the designer can call this procedure either by menu procedures or buttons.
- `this procedure assumes you are using at least three buttons with these names
- `and only one line in their script
- `SpeechPlay
- ` SPEAK(Last Area;1)
- `SpeechStop
- ` SPEAK(Last Area;2)
- `SpeechPause
- ` SPEAK(Last Area;2)
- `of which 'SCRIPT: Only if modified' is enabled
- `BTW 'Last Area' can be every other pointer ofcourse
- `if you want to allow only to speak a text field use a pointer to that field
-
- `from the layout procedure you can call:
- ` SPEAK(Last Area;0)
- `to reset the button state correctly
- `(in this case the pointer is ignored)
-
- C_INTEGER($err;$first;$last)
- C_STRING(255;$speakstring)
-
- If (Not(Nil($1)))`if parameter is valid pointer
- If (SP Can speak >0)`if we can speak do so and set buttons accordingly
- Case of
- : ($2=1)`play
- If (SP Voice busy (SpeechRef)=2)`if the voice is paused than this selector acts as 'continue'
- $err:=SP Voice Cont (SpeechRef)`thus: continue speaking
-
- Else `the voice is not paused so just speak the data
- If (Type($1»)=2)`since a text field has its own Speech Pack command…
- GET HIGHLIGHT($1»;$first;$last)`get the selection of the text
- $err:=SP Voice Text (SpeechRef;$1»;$first;$last;0)`and say it
- Else `everything else but a text field ends here
- Case of `convert the field data into a string based on the data type
- : (Type($1»)=0)`normal string
- $speakstring:=$1»`just copy it
- : (Type($1»)=1)`real
- $speakstring:=String($1»)`convert using String
- : (Type($1»)=4)`date
- $speakstring:=String($1»;3)`convert using String with the long format
- : (Type($1»)=6)`boolean
- $speakstring:=("true"*Num($1»))+("false"*Num(Not($1»)))`difficult what to say, simple TRUE or FALSE I guess
- : (Type($1»)=8)`integer
- $speakstring:=String($1»)`convert using String
- : (Type($1»)=9)`long int
- $speakstring:=String($1»)`convert using String
- : (Type($1»)=11)`time
- $speakstring:=String($1»;5)`convert using String with the hh:mm AM/PM format
- Else
- $speakstring:=""`anything else gives an empty string
- End case
-
- If ($speakstring#"")`if empty don't try it, interrupt previous speaking
- $err:=SP Voice String (SpeechRef;$speakstring)`say it!
- End if
-
- End if
-
- End if
-
- `much simpler now: (we're are still in the case statement for the selector!)
- : ($2=2)`stop
- $err:=SP Voice Stop (SpeechRef)`stop the voice (testing if busy is done by external)
- : ($2=3)`pause
- $err:=SP Voice Pause (SpeechRef)`pause the voice (testing if busy is done by external)
- End case
-
- `now set the buttons
- $status:=SP Voice busy (SpeechRef)`the others depend on the state of speaking
- Case of
- : ($status=0)`idle
- ENABLE BUTTON(SpeechPlay)`play is always enabled
- DISABLE BUTTON(SpeechStop)`the voice is not active so disabled
- DISABLE BUTTON(SpeechPause)
- : ($status=1)`busy
- ENABLE BUTTON(SpeechPlay)`play is always enabled
- ENABLE BUTTON(SpeechStop)`user can either stop…
- ENABLE BUTTON(SpeechPause)`or pause
- : ($status=2)`paused
- ENABLE BUTTON(SpeechPlay)`play is always enabled
- ENABLE BUTTON(SpeechStop)`user can stop but…
- DISABLE BUTTON(SpeechPause)`voice paused already
- Else
- DISABLE BUTTON(SpeechPlay)`the voice is not active so disable all
- DISABLE BUTTON(SpeechStop)
- DISABLE BUTTON(SpeechPause)
- End case
-
- Else
-
- DISABLE BUTTON(SpeechPlay)`can't speak so disable buttons
- DISABLE BUTTON(SpeechStop)
- DISABLE BUTTON(SpeechPause)
-
- End if
- End if
-
-
-
-